package com.mcxx.formulcount.gonshi;

import java.util.Arrays;


public class LgOperateSymbol extends OperateSymbol {

	public LgOperateSymbol(String symb, int prio){
		 super(symb, prio);
    }
	public Object  Caluc(Object pA, Object ... B) throws Exception
    {
        if (symbol.equals("[and]"))
        {
            if (Integer.parseInt(pA.toString()) == 1 &&
            		Integer.parseInt(B[0].toString()) == 1) {
                return 1;
            } else {
                return 0;
            }
        }
        if (symbol.equals("[or]"))
        {
            if (Integer.parseInt(pA.toString()) == 0 && Integer.parseInt(B[0].toString()) == 0) {
                return 0;
            } else {
                return 1;
            }
        }
        if (symbol.equals("[not]"))
        {
            return Integer.parseInt(pA.toString()) == 1 ? 0 : 1;
        }
        if (symbol == "[in]")
        {
            String[] arr = B[0].toString().split(",");
            return Arrays.asList(arr).contains(pA.toString()) ? 1 : 0;
        }
        throw new Exception("不支持的运算符:"+symbol);
    }
}
